package com.jianganming.observer.demo3;


import java.util.Observable;
import java.util.Observer;

//Observer jdk提供的观察者接口
//观察者对象
public class Student implements Observer {
    private String name;

    public Student(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //接收广播消息
    @Override
    public void update(Observable o, Object arg) {
        Teacher teacher = (Teacher)o;
        System.out.println("收到"+teacher.getName()+"的通知");
        System.out.println(name+"说：好的，我马上到。");
    }
}
